<?php
namespace app\admin\logic;
use app\admin\BaseController;
use think\facade\Filesystem;
use think\facade\Request;

class Admin extends BaseController
{
    //useradd添加
    public static function adminAddWhere()
    {
        if (Request::isPost()){
            $post=Request::post();
            $where=[];

            $file=Request::file();
            if (isset($file) && $file!=''){
                validate(['logo'=>'filesize:99910240|fileExt:jpg,png'])->check($file);
                $file=Filesystem::putFile('images',$file['logo'],'md5');
                $file=str_replace('/','\\',$file);
                $where['headimg']=$file;
            }
            if (isset($post['name']) && $post['name']!=''){
                $where['name']=$post['name'];
            }
            if (isset($post['pwd']) && $post['pwd']!=''){
                $where['pwd']=md5($post['pwd']);
            }
            if (isset($post['email']) && $post['email']!=''){
                $where['email']=$post['email'];
            }
            if (isset($post['tel']) && $post['tel']!=''){
                $where['tel']=$post['tel'];
            }
            if (isset($post['author']) && $post['author']!=''){
                $where['author']=$post['author'];
            }
            $where['addtime']=time();
            return $where;

        }
    }
    //useredit 修改的条件
    public static function userEdit()
    {
        if (Request::isPost()){
            $post=Request::post();
            $where=[];

            $file=Request::file();
            if (isset($file) && $file!=''){
                validate(['logo'=>'filesize:99910240|fileExt:jpg,png'])->check($file);
                $file=Filesystem::putFile('images',$file['logo'],'md5');
                $file=str_replace('/','\\',$file);
                $where['headimg']=$file;
            }
            if (isset($post['id']) && $post['id']!=''){
                $where['id']=$post['id'];
            }
            if (isset($post['email']) && $post['email']!=''){
                $where['email']=$post['email'];
            }
            if (isset($post['tel']) && $post['tel']!=''){
                $where['tel']=$post['tel'];
            }
            if (isset($post['author']) && $post['author']!=''){
                $where['author']=$post['author'];
            }
            $where['addtime']=time();


            return $where;
            }

    }

}